package com.yoki.cloud.common.protocol.radius.attribute.attr.acct;

import com.yoki.cloud.common.protocol.radius.attribute.attr.type.IntegerTypeAttr;
import lombok.Getter;

/**
 * @author Sky$
 * @Description: TODO
 * @date 2018/1/15$ 14:54$
 */
public class AcctStatusTypeAttr extends IntegerTypeAttr {

    public static final int ATTR_TYPE = 40;

    @Override
    public int getAttrType() {
        return ATTR_TYPE;
    }

    public AcctStatusTypeEnum getAcctStatusType() {
        return AcctStatusTypeEnum.getByValue(this.value);
    }

    public enum AcctStatusTypeEnum {

        Start(1, "Stop"),
        Stop(2, "Stop"),
        Interim_Update(3, "Interim-Update"),
        Accounting_On(4, "Accounting-On"),
        Accounting_Off(5, "Accounting-Off");

        @Getter
        private int value;
        @Getter
        private String name;

        AcctStatusTypeEnum(int value, String name) {
            this.value = value;
            this.name = name;
        }

        public static AcctStatusTypeEnum getByValue(Integer value) {
            if (null == value) {
                throw new IllegalArgumentException();
            }
            AcctStatusTypeEnum[] enums = AcctStatusTypeEnum.values();
            for (AcctStatusTypeEnum e : enums) {
                if (e.getValue() == value.intValue()) {
                    return e;
                }
            }
            return null;
        }

    }

}
